USE [CTEM-DB-v1]
GO
/****** Object:  StoredProcedure [dbo].[Construction_GetAll]    Script Date: 11/17/2011 15:27:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


-- =============================================
-- Author:		TienDH
-- Create date: 12/05/2011
-- Description:	Get full employee's information
-- =============================================
CREATE PROCEDURE [dbo].[Construction_GetMainConstruction]
AS
BEGIN
	SELECT	C.*, WH.WarehouseID,s.SubcontractorName,e.TotalCostEstimate,e.TotalCostReal,e.EstimateID,m.Username
	FROM Construction C LEFT OUTER JOIN Warehouse WH ON C.ConstructionID = WH.ConstructionID
		    LEFT OUTER JOIN Subcontractor s 
			ON s.SubcontractorID = c.SubcontractorID 
			LEFT OUTER JOIN Estimate e
			ON e.ConstructionID = c.ConstructionID 
			LEFT OUTER JOIN Employee m
			ON c.ManagerID = m.EmployeeID 
	WHERE c.IsDeleted!=1 AND C.ParentID = 0
END


